﻿using Omabar.BLL;
using Omabar.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Omabar.CMS.CMS
{
    public partial class RouteEdit : System.Web.UI.Page
    {
        protected string id;
        protected ROUTE route;

        protected List<HOTEL> hotels;
        protected List<PHOTO> photos;
        protected List<ROUTE_COUNTRY> citys;
        protected List<SPECIALITEM> specialItems;
        protected List<TRIP> trips;
        protected List<THEME> themes;
        protected List<CHARACTERISTIC> cctss;
        protected void Page_Load(object sender, EventArgs e)
        {
            Route_BLL routeBLL = new Route_BLL();
            Hotel_BLL hotelBLL = new Hotel_BLL();
            CityBelong_BLL cbBLL = new CityBelong_BLL();
            Photo_BLL photoBLL = new Photo_BLL();
            SpecialItem_BLL specialItemBLL = new SpecialItem_BLL();
            Trip_BLL tripBLL = new Trip_BLL();
            Theme_BLL themeBLL = new Theme_BLL();
            Characteristic_BLL cctsBLL = new Characteristic_BLL();

            if (!IsPostBack)
            {
                id = Request["id"];
                route = routeBLL.GetModel(id);

                //酒店
                hotels = hotelBLL.GetModels(string.Format("select Top 10 v.HOTEL_ID,HOTEL_NAME,HOTEL_DES,HOTEL_ADDRESS,HOTEL_WEBSITE,HOTE_DETAIL FROM ROUTE_HOTEL T LEFT JOIN HOTEL V ON T.HOTE_ID=V.HOTEL_ID WHERE T.ROUTE_ID='{0}'", id));
                //图库
                photos = photoBLL.GetModels(string.Format("SELECT TOP 10 T.PHOTO_ID,PHOTO_NAME,PHOTO_URL,PHOTO_DES,PHOTO_HOT,PHOTO_COVER FROM ROUTE_GALLERY T LEFT JOIN PHOTO V ON T.PHOTO_ID=V.PHOTO_ID WHERE T.ROUTE_ID='{0}'", id));
                if (photos == null) photos = new List<PHOTO>();
                //特色项目
                specialItems = specialItemBLL.GetModels(string.Format("select Top 10 v.SPECIALITEM_ID,SPECIALITEM_NAME,SPECIALITEM_PRICE,SPECIALITEM_DES,SPECIALITEM_COVER FROM ROUTE_SPECIALITEM T LEFT JOIN SPECIALITEM V ON T.SPECIALITEM_ID=V.SPECIALITEM_ID WHERE T.ROUTE_ID='{0}'",id));
                //行程
                trips = tripBLL.GetModels(string.Format("select Top 10 v.TRIP_ID,TRIP_NAME,TRIP_FOOD,TRIP_DES FROM ROUTE_TRIP T LEFT JOIN TRIP V ON T.TRIP_ID=V.TRIP_ID WHERE T.ROUTE_ID='{0}'", id));
                //城市
                citys = cbBLL.GetModels(string.Format("SELECT TOP 10 ROUTE_ID,ROUTE_CONTINENT,ROUTE_COUNTRY_NAME,ROUTE_CITY FROM ROUTE_COUNTRY WHERE ROUTE_ID='{0}'", id));
                //主题
                themes = themeBLL.GetModels(string.Format("select Top 10 v.THEME_ID,THEME_NAME,THEME_DES FROM ROUTE_THEME T LEFT JOIN THEME V ON T.THEME_ID=V.THEME_ID WHERE T.ROUTE_ID='{0}'", id));
                //特点 取消
                //cctss = cctsBLL.GetModels(string.Format("select Top 10 CHARACTERISTIC_ID,CHARACTERISTIC_NAME,CHARACTERISTIC_DES FROM ROUTE_CHARACTERISTIC T LEFT JOIN CHARACTERISTIC V ON T.CHARACTERISTIC_ID=V.CHARACTERISTIC_ID WHERE T.ROUTE_ID='{0}'", id));
            }
        }
    }
}